// 基于template/src/widgets/{{appEntities}}/{{ctrls@GRID}}-grid/{{spinalCase ctrl.codeName}}-grid-model.ts.hbs生成
import { IGridModel, IParam, isEmpty, VerifyUtil } from '@/core';

function getModel(): IGridModel {
	return {
		cssName: '',
		aggMode: 'NONE',
		caption: '',
		controlType: 'GRID',
		codeName: 'Main',
		columns: getGridColumns(),
		dataItems: getGridDataItems(),
		dataExport: getDataExport(),
		enableRowEdit: false,
		entityCodeName: 'OPEN_ACCESS',
		entityLogicName: '开放接入',
		createDefaultItems: getCreateDefaultItems(),
		updateDefaultItems: getUpdateDefaultItems(),
		name: 'grid',
		noSort: false,
		rules: {
			//	静态值规则
			staticRules: {},
			//	编辑项值规则
			editRules: [],
		},
		showHeader: true,
		sortDir: '',
		sortField: '',
		limit: 20,
		paging: {
			defaultPageSize: 20,
		},
		uiEngineModel: [
			{
				name: 'engine_grid',
				triggerType: 'CTRLEVENT',
				logicType: 'APPVIEWENGINE',
				eventNames: 'ROWDBLCLICK;SELECTIONCHANGE;REMOVE;LOAD;BEFORELOAD',
				scriptCode: ``,
				entityCodeName: '',
				logicName: ``,
			},
		],
	};
}
//  获取所有表格列模型
function getGridColumns(): IParam[] {
	return [
		{
			align: 'left',
			codeName: 'name',
			caption: '名称',
			captionLanResTag: 'DEF.LNAME.NAME',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'name',
			dataIndex: 'name',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '名称',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'name',
			width: 150,
			minWidth: 150,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'open_type',
			caption: '类型',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			codeListTag: 'open__Open_access_type_justAuth',
			dataItemName: 'open_type',
			dataIndex: 'open_type',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '类型',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'open_type',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'access_key',
			caption: 'AccessKey(AppId)',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'access_key',
			dataIndex: 'access_key',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: 'AccessKey(AppId)',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'access_key',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'disabled',
			caption: '是否禁用',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			codeListTag: 'YesNo',
			dataItemName: 'disabled',
			dataIndex: 'disabled',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '是否禁用',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'disabled',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 9,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'redirect_uri',
			caption: '重定向地址',
			captionLanResTag: '',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'redirect_uri',
			dataIndex: 'redirect_uri',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '重定向地址',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'redirect_uri',
			width: 100,
			minWidth: 100,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
		{
			align: 'left',
			codeName: 'id',
			caption: '标识',
			captionLanResTag: 'DEF.LNAME.ID',
			cellCssName: '',
			columnType: 'DEFGRIDCOLUMN',
			valueType: 'SIMPLE',
			dataItemName: 'id',
			dataIndex: 'id',
			sorter: true,
			enableRowEdit: false,
			customFilterDropdown: false,
			filterName: '',
			filterCodeListTag: '',
			filterCodeListType: '',
			enableSort: true,
			excelCaption: '标识',
			headerCssName: '',
			show: true,
			hiddenDataItem: false,
			name: 'id',
			width: 250,
			minWidth: 250,
			resizable: true,
			stdDataType: 25,
			valueFormat: '',
		},
	];
}

//  获取所有表格数据项
function getGridDataItems() {
	return [
		{
			name: 'name',
			codeName: '',
			customCode: false,
			fieldCodeName: 'name',
			fieldName: 'name',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'open_type',
			codeName: '',
			customCode: false,
			fieldCodeName: 'open_type',
			fieldName: 'open_type',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'access_key',
			codeName: '',
			customCode: false,
			fieldCodeName: 'access_key',
			fieldName: 'access_key',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'disabled',
			codeName: '',
			customCode: false,
			fieldCodeName: 'disabled',
			fieldName: 'disabled',
			valueFormat: '',
			dataType: '9',
		},
		{
			name: 'redirect_uri',
			codeName: '',
			customCode: false,
			fieldCodeName: 'redirect_uri',
			fieldName: 'redirect_uri',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'id',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'id',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'srfkey',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'id',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'srfdataaccaction',
			codeName: '',
			customCode: false,
			fieldCodeName: 'id',
			fieldName: 'id',
			valueFormat: '',
			dataType: '25',
		},
		{
			name: 'srfmajortext',
			codeName: '',
			customCode: false,
			fieldCodeName: 'name',
			fieldName: 'name',
			valueFormat: '',
			dataType: '25',
		},
	];
}

function getDataExport() {
	return {
		default: true,
		codeName: 'default',
		enableFront: true,
		fileName: '开放接入',
		exportItems: [
			{
				name: 'name',
				label: '名称',
				labelLanResTag: 'DEF.LNAME.NAME',
				dataType: 25,
				show: true,
			},
			{
				name: 'open_type',
				label: '类型',
				labelLanResTag: '',
				dataType: 25,
				codeListTag: 'open__Open_access_type_justAuth',
				show: true,
			},
			{
				name: 'access_key',
				label: 'AccessKey(AppId)',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'disabled',
				label: '是否禁用',
				labelLanResTag: '',
				dataType: 9,
				codeListTag: 'YesNo',
				show: true,
			},
			{
				name: 'redirect_uri',
				label: '重定向地址',
				labelLanResTag: '',
				dataType: 25,
				show: true,
			},
			{
				name: 'id',
				label: '标识',
				labelLanResTag: 'DEF.LNAME.ID',
				dataType: 25,
				show: true,
			},
		],
	};
}

function getCreateDefaultItems() {
	return [];
}

function getUpdateDefaultItems() {
	return [];
}

export const model = getModel();
